//备注：拷贝代码请加上作者信息
//作者：王海涛
//邮箱：1126471088@qq.com
//版本：V0.1.0
/********************************************************
    说明：
**********************************************************/
#ifndef __W5500_DRIVER_H__
#define __W5500_DRIVER_H__

#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "../../../BSP/SPI_BSP/spi_bus.h"
#include "../../../BSP/GPIO_BSP/gpio_bsp.h"


//SPI NSS
#define W5500_NSS_GPIO_PORT     PortB
#define W5500_NSS_GPIO_PIN     	Pin12
//Reset
#define W5500_RESET_GPIO_PORT   PortC
#define W5500_RESET_GPIO_PIN    Pin13
//INT
#define W5500_INT_GPIO_PORT     PortC
#define W5500_INT_GPIO_PIN     	Pin14

typedef enum
{
    W5500_TRx_Idle = 0,//空闲
    W5500_TRx_Busy = 1,//忙碌

    W5500_No_Error = 0,//无错误码
	W5500_Error    = 1,//通信错误
}WHT_W5500_State_enum;

typedef struct
{
	WHT_W5500_State_enum Idle_State; //自动清除
	WHT_W5500_State_enum Error_State;//错误状态,自动清除
}WHT_W5500_State_t;


typedef struct
{
	volatile WHT_W5500_State_t* WHT_State;//状态
	void (*WHT_Init)(void);               //初始化
    void (*WHT_Reset)(void);
    char (*WHT_Get_Int_State)(void);
	void (*WHT_Read_Data)(uint8_t* const input_buf,uint8_t* const output_buf, uint32_t count);
	void (*WHT_Write_Data)(uint8_t* const input_buf, uint32_t count);
}WHT_W5500_Driver_t;

extern WHT_W5500_Driver_t WHT_W5500_Driver;

#endif /*__W5500_DRIVER_H__*/
